<template>
  <div class="item" @click="itemClick">
    <div v-if="!isActive">
      <slot name="item-icon"></slot>
    </div>
    <div v-else>
      <slot name="item-icon-active"></slot>
    </div>
    <div :style="activeStyle">
      <slot name="text"></slot>
    </div>
    <!-- <img src="../../assets/img/Index.svg" alt="">
    <div>
      首页
    </div> -->
  </div>
</template>

<script>
  export default {
    name: 'TabBsrItem',
    props: {
      path: String,
      // 动态设置字体切换的颜色
      ActiveColor: {
        type: String,
        default: 'blue'
      }
    },
    data() {
      return {
        // isActive: true
      }
    },
    computed: {
      isActive() {
        // 不等于-1说明路径是相同的
        return this.$route.path.indexOf(this.path) !== -1
      },
      activeStyle() {
        // 动态设置颜色
        return this.isActive ? {
          color: this.ActiveColor
        } : {}
      }
    },
    methods: {
      itemClick() {
        this.$router.replace(this.path)
      }
    }
  }
</script>

<style scoped lang="less">
  .item {
    height: 49px;
    flex: 1;

    img {
      width: 24px;
    }
  }

  // .active {
  //   color: red;
  // }
</style>